﻿namespace NetFx.SMIL
{
  using System;
  using System.Text;
  using NetFx.AGIL;

  /// <summary>
  /// Smil操作。
  /// </summary>
  /// 
  public class SmilOperation
  {
    #region Nested classes
    public class Idle : SmilOperand
    {

    }
    #endregion
    #region Statics
    public static SmilOperation of(SmilOpcode opcode)
    {
      return new SmilOperation(opcode);
    }
    public static SmilOperation of(SmilOpcode opcode, SmilOperand operand)
    {
      return new SmilOperation(opcode, operand);
    }

    #endregion
    #region Fields
    protected SmilOpcode opcode;
    protected SmilOperand operand;
    #endregion
    #region Properties
    public virtual SmilOpcode Opcode
    {
      get
      {
        return this.opcode;
      }
    }
    public virtual SmilOperand Operand
    {
      get
      {
        return this.operand;
      }
      set
      {
        this.operand = value;
      }
    }
    public virtual SmilOperandType OperandType
    {
      get
      {
        return this.Opcode.OperandType;
      }
    }
    public virtual bool MissingOperand
    {
      get
      {
        return (
          this.OperandType != SmilOperandType.None &&
          this.operand == null
          );
      }
    }
    #endregion
    #region Constructors
    public SmilOperation()
      : this(null)
    {

    }
    public SmilOperation(SmilOpcode opcode)
      : this(opcode, null)
    {

    }
    public SmilOperation(SmilOpcode opcode, SmilOperand operand)
    {
      this.opcode = opcode;
      this.operand = operand;
    }
    #endregion
    #region Methods
    public virtual AgilOperation ToAgil()
    {
      return null;
    }
    public virtual SmilOperation Clone()
    {
      return of(this.opcode, this.operand);
    }
    public virtual void LogFormatAt(OperationFormatResolver resolver)
    {
      if (resolver != null)
      {
        this.OnLogFormatAt(resolver);
      }
    }
    public virtual void SetFormatAt(OperationFormatResolver resolver,bool? isLongFormat)
    {
      if (resolver != null)
      {
        this.OnSetFormatAt(resolver,isLongFormat);
      }
    }
    protected  virtual void OnLogFormatAt(OperationFormatResolver resolver)
    {

    }
    protected virtual void OnSetFormatAt(OperationFormatResolver resolver, bool? isLongFormat)
    {

    }
    #endregion
  }
}
